<?php 
namespace Home\Controller;
use Think\Controller;
use Think\Verify;
class UserController extends Controller{
	//登录
	public function login(){
			if(!empty($_POST)){
						$man = new \Home\Model\UserModel();
						$count=array('username' => $_POST['username']);
						$a = $man->where($count)->find();
					if(!$a){
							dump('用户名错误');
					}else{
							if(!$man->checkPwd()){
								dump('密码错误');
							}else{					
								session('username',$a['username']);
								session('password',$a['password']);
								$this->redirect('User/yonghu','',1,'登陆成功');
							}
					}
				
			}else{
				$this->display();
			}
		}

	//注册
	public function register(){
		$user=new \Home\Model\UserModel();
		if(!empty($_POST)){
			$info=$user->create();
			$info['user_hobby']=implode(',',$_POST['user_hobby']);
			if($info){
				 $a = $user->add($info);
				if($a){
					$this->success('成功',U('Home/User/login'));
					}		
			}else{
				$this->assign('errorinfo',$user->getError());
			}			
		}
			$this->display();	
	}
	public function shouhuo(){
		$this->display('user/ucenter2');
	}
}

 ?>